<?php 
session_start();
include('config.inc.php');
// session variable
$sess_id=$_SESSION['sess_id'];
$sess_user=$_SESSION['sess_user'];
$sess_status=$_SESSION['sess_status'];
$flag = $_SESSION['sess_flag'];

echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$charset\" />";

?>
<html>
<head>
<title>FCR</title>

<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript" src="js/epoch_classes.js"></script>
<script type="text/javascript" src="js/autocomplete.js"></script>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="autocomplete.css"  type="text/css"/>
<link rel="stylesheet" type="text/css" href="epoch_styles.css" />
</head>
<?php
if ($sess_id<>session_id() || $sess_user=="" || $sess_status<>"active") {
	echo "<body>";
}else{
	echo "<body onload=\"javascritp:showPage();javascript:HideContent('ucontent');\">";
}
?>
<div align="center">
<?php 
//<!-- Header -->
echo "<div id=\"header\">
    	<div id=\"logo\">
			TT&T Public Co., Ltd.
    	</div>
        <div id=\"address\" align=\"left\">".$address."
        </div>
        <div id=\"menu\">
        	<a href=\"index.php\" id=\"on\">หน้าแรก</a>  
			<a href=\"http://web.ttt.co.th\">Intranet</a>";
			if($flag == '4' && $sess_user<> ""){
				echo "<a href=\"admin/index.php\">Control panel</a>";
			}
	  echo "<a href='logout.php'>logout</a>
        </div>
      </div>";
//<!-- Body -->
echo "<div id=\"content\" align=\"justify\">";

if ($sess_id<>session_id() || $sess_user=="" || $sess_status<>"active") {
		echo "<div id='' style='padding:10px 0px 10px 20px;'>";
		include('login.php');
		echo "</div>";
		exit();
	}
	
$loginuser = mysql_num_rows(mysql_query("SELECT * FROM USERS u join flag_detail fd on u.flag=fd.flag_id WHERE USERNAME = '$sess_user'"));
$getu = mysql_fetch_array(mysql_query("SELECT * FROM USERS u join flag_detail fd on u.flag=fd.flag_id WHERE USERNAME = '$sess_user'"));
echo "<span><input type='button' value='ซ่อน/แสดง ข้อมูลผู้ใ้ช้' onClick=\"javascript:ReverseDisplay('ucontent');\" style='border:1px;color:#FFFFFF;background:#666666;'align='left'></span>";
echo "<div id='ucontent'>";
echo "<div align='right' style='padding-right:60px;'>
		<div style='padding:18px 0px 0px 20px;'><a href=\"javascript:showDetail('$_SESSION[sess_user]');\" class='b-link'>ข้อมูลผู้ใช้</a> <a href=\"javascript:edituser('$_SESSION[sess_user]');\" class='b-link'> แก้ไขข้อมูล</a></div>";
echo "</div>";
echo "<div id='sectoruser' style='padding:10px 20px 10px 20px;border:1px dashed #999999;margin:10px;'>";
if($loginuser != 0){
echo "<script language=\"JavaScript\">";
echo "showDetail('".$_SESSION[sess_user]."');";
echo "</script>";
/*echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" background='images/bg_header.jpg'>
      <tr >
      <td width=\"42%\" style='padding:5px 0px 5px 10px;'><small><font color='#FFFFFF'>สวัสดี คุณ ".$getu['name']."</font></small></td>
      <td width=\"31%\" style='padding:5px 0px 5px 10px;'><small><font color='#FFFFFF'>หน่วยงาน ".$getu['unit_code']."</font></small></td>
      <td width=\"27%\" style='padding:5px 0px 5px 10px;'><small><font color='#FFFFFF'>จังหวัด ".$getu['pnthai']."</font></small></td>
      </tr>
      <tr >
      <td style='padding:5px 0px 5px 10px;'><small><font color='#FFFFFF'>อีเมลล์ ".$getu['username']."@ttt.co.th</font></small></td>
      <td width=\"31%\" style='padding:5px 0px 5px 10px;'><small><font color='#FFFFFF'>โทรศัพท์ ".$getu['tel']."</font></small></td>
      <td width=\"27%\" style='padding:5px 0px 5px 10px;'><small><font color='#FFFFFF'>โทรสาร ".$getu['fax']."</font></small></td>
      </tr>
      <tr >
      <td  style='padding:5px 0px 5px 10px;'><small><font color='#FFFFFF'>สถานะ ".$getu['flag_name']."</font></small></td>
      <td width=\"31%\" style='padding:5px 0px 5px 10px;'><small><font color='#FFFFFF'>&nbsp;</font></small></td>
      <td width=\"27%\" style='padding:5px 0px 5px 10px;'><small><a href='logout.php' style='text-decoration:none;'><font color='#FFFFFF'>ออกจากระบบ</font></a></small></td>
      </tr>
    </table>
";*/
}
echo "</div>";
echo "</div>";
if($flag == 1 || $flag == 2 || $flag == 3 || $flag == 4 ){ 	
	echo "<div id=\"menutabs\">";
	echo "<a href=\"javascript:showPage('welcome.php');\">อุปกรณ์สำนักงาน</a>";
	echo "<a href=\"javascript:showPage('process.php');\">แจ้งเหตุเสีย</a>";
	echo "<a href=\"javascript:showPage('search.php');\">ค้นหาการแจ้งเสีย</a>";
	echo "<a href=\"javascript:showPage('showdetail.php');\">ประวัติการแจ้ง</a>";
	echo "</div>";
}else{
	echo "<a href=\"#\">คุณไม่ได้รับอนุญาติให้ทำรายการใดๆ</a>";
	exit();
}
//-- <a href="#" class="tabon">Software</a><a href="#">Hardware</a><a href="#">Periferals</a><a href="#">Laptops</a> -->
echo "<br/>
		<div id='leftshow'></div>
		<div id='left'></div>
        <div id=\"showright\"></div>
        <div style=\"clear:both\"></div>";
		//}
echo "</div>";
//<!-- Footer -->
echo $footer;
?>
</div>
</body>
</html>
